package com.sbtr.business.classify.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sbtr.business.classify.dto.AlgoTemplateFileDto;
import com.sbtr.business.classify.entity.AlgoTemplateFile;
import com.sbtr.business.classify.mapper.AlgoTemplateFileMapper;
import com.sbtr.business.classify.service.AlgoTemplateFileService;
import com.sbtr.common.PageDto;
import com.sbtr.util.PageDtoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 轻量化算法模板字段列表 Service接口实现类
 *
 * @author dgl
 * @since 2023-06-13
 */
@Transactional
@Service
public class AlgoTemplateFileServiceImpl extends ServiceImpl<AlgoTemplateFileMapper, AlgoTemplateFile> implements AlgoTemplateFileService {

    @Resource
    AlgoTemplateFileMapper algoTemplateFileMapper;

    @Override
    public PageDto<AlgoTemplateFile> pageList(AlgoTemplateFileDto algoTemplateFileDto) {

        IPage<AlgoTemplateFile> page = new Page<>();
        page.setSize(algoTemplateFileDto.getPageSize());
        page.setCurrent(algoTemplateFileDto.getPage());
        page = algoTemplateFileMapper.selectPages(page, BeanUtil.beanToMap(algoTemplateFileDto));
        PageDto<AlgoTemplateFile> r = PageDtoUtils.getPageDtoByIPage(page, AlgoTemplateFile.class);

        return r;
    }
}

